/*wxBtVHTjruFsGR5nLWPsoFBgJFTT8CHaSJJfiBimilTHOdBXLe68tIk4NpS5xcs5*/
/*
 * @Author: xiahui 
 * @PageInfo: 查询、刷新公共方法
 * @Date: 2019-03-04 20:36:17 
 * @Last Modified by: xiahui
 * @Last Modified time: 2019-07-13 09:49:00
 */
import { ajax } from 'nc-lightapp-front';
import { AREA, URL, BUTTONID, UISTATUS } from '../../constance';
import {
	showHasQueryResultInfo,
	showNoQueryResultInfo,
	showRefreshInfo
} from '../../../../../scmpub/scmpub/pub/tool/messageUtil';
import { buttonControl } from '../viewControl/buttonControl';

export default function(props, queryInfo, isRefresh = false) {
	queryInfo.pageInfo = props.editTable.getTablePageInfo(AREA.listTableId); //分页信息;

	ajax({
		url: URL.query,
		data: queryInfo,
		success: (res) => {
			if (res.formulamsg && res.formulamsg instanceof Array && res.formulamsg.length > 0) {
				props.dealFormulamsg(
					res.formulamsg //参数一：返回的公式对象
				);
			}
			if (res.success) {
				if (res.data) {
					isRefresh ? showRefreshInfo() : showHasQueryResultInfo(res.data[AREA.listTableId].rows.length);
					props.editTable.setTableData(AREA.listTableId, res.data[AREA.listTableId]);
					props.button.setDisabled([ BUTTONID.Edit, BUTTONID.Print ], false);
				} else {
					isRefresh ? showRefreshInfo() : showNoQueryResultInfo();
					props.editTable.setTableData(AREA.listTableId, { rows: [] });
					props.button.setDisabled([ BUTTONID.Edit, BUTTONID.Print ], true);
				}
				props.button.setDisabled([ BUTTONID.Refresh ], false);
				// 按钮状态控制
				buttonControl.call(this, props, UISTATUS.browse);
			}
		}
	});
}

/*wxBtVHTjruFsGR5nLWPsoFBgJFTT8CHaSJJfiBimilTHOdBXLe68tIk4NpS5xcs5*/